package com.example.light.web.meeting.service;

import com.example.light.web.meeting.dao.OaMachineMapper;
import com.example.light.web.meeting.entity.OaMachine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

@Service
public class OaMachineServiceImpl implements OaMachineService {
    @Autowired
    private OaMachineMapper machineMapper;
    @Override
    public void machineList(Model model) {
        List<OaMachine> machineList=machineMapper.queryMachine();
        model.addAttribute("machineList",machineList);
    }

    @Override
    public void addMachine(OaMachine machine) {
        machineMapper.insertSelective(machine);
    }

    @Override
    public OaMachine querySingle(Integer mId, Model model) {
       OaMachine machine=machineMapper.selectByPrimaryKey(mId);
       return  machine;
    }

    @Override
    public void addModel(Model model, OaMachine editMachine) {
        model.addAttribute("mId",editMachine.getmId());
        model.addAttribute("mCondition",editMachine.getmCondition());
        model.addAttribute("mDescription",editMachine.getmDescription());
        model.addAttribute("mUser",editMachine.getmUser());
        model.addAttribute("mScene",editMachine.getmScene());

    }

    @Override
    public void editMachine(OaMachine machine) {
        machineMapper.updateByPrimaryKeySelective(machine);
    }

    @Override
    public void delMachine(int[] delInfo) {
        for(int i=0;i<delInfo.length;i++){
            machineMapper.deleteByPrimaryKey(delInfo[i]);
        }
    }
}
